bitkeeper revision 1.43 (3e4e61d8nVp2Sx8XMCpKhj4KfuEEVQ)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Sat, 15 Feb 2003 15:50:48 +0000 (15:50 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Sat, 15 Feb 2003 15:50:48 +0000 (15:50 +0000)
Partial fix to ensure that the IDE driver maps buffers into Xen
memoey before doing PIO cycles to them. The ATAPI case has not been
covered, and the mappings are short lived and conservative. Hopefully
this code path will not be used for bulk data transfer due to DMA.

xen-2.4.16/drivers/ide/ide-taskfile.c
xen-2.4.16/drivers/ide/ide.c

index 578af551566250f9b407547bfdd451246abacea3..6e1286165fb9a4b20877ba27926cc2ac090f0098 100644 (file)
@@ -27,6 +27,7 @@
 #include <xeno/hdreg.h>
 #include <xeno/ide.h>
 
+#include <asm/domain_page.h>
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -82,10 +83,12 @@ static inline void task_vlb_sync (ide_ioreg_t port) {
 /*
  * This is used for most PIO data transfers *from* the IDE interface
  */
-void ata_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+void ata_input_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
 {
        byte io_32bit = drive->io_32bit;
 
+        void *buffer = map_domain_mem(virt_to_phys(vbuffer));
+
        if (io_32bit) {
 #if SUPPORT_VLB_SYNC
                if (io_32bit & 2) {
@@ -110,15 +113,19 @@ void ata_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 #endif /* SUPPORT_SLOW_DATA_PORTS */
                        insw(IDE_DATA_REG, buffer, wcount<<1);
        }
+
+       unmap_domain_mem(buffer);
 }
 
 /*
  * This is used for most PIO data transfers *to* the IDE interface
  */
-void ata_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+void ata_output_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
 {
        byte io_32bit = drive->io_32bit;
 
+        void *buffer = map_domain_mem(virt_to_phys(vbuffer));
+
        if (io_32bit) {
 #if SUPPORT_VLB_SYNC
                if (io_32bit & 2) {
@@ -143,6 +150,8 @@ void ata_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 #endif /* SUPPORT_SLOW_DATA_PORTS */
                        outsw(IDE_DATA_REG, buffer, wcount<<1);
        }
+
+       unmap_domain_mem(buffer);
 }
 
 
index 51cee21f775b0af677e3ebc3d1b64e0565bb1034..1db4e34834bf67beb18bbc5563c382c908df1998 100644 (file)
 /*#include <xeno/completion.h>*/
 /*#include <xeno/reboot.h>*/
 
+#include <asm/domain_page.h>
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -413,8 +414,9 @@ static inline void do_vlb_sync (ide_ioreg_t port) {
 /*
  * This is used for most PIO data transfers *from* the IDE interface
  */
-void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+void ide_input_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
 {
+        void *buffer;
        byte io_32bit;
 
        /* first check if this controller has defined a special function
@@ -423,10 +425,17 @@ void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 
        if(HWIF(drive)->ideproc) {
                HWIF(drive)->ideproc(ideproc_ide_input_data,
-                                    drive, buffer, wcount);
+                                    drive, vbuffer, wcount);
                return;
        }
 
+       /* We assume controllers own functions will make their own
+         * arrangemnets for mapping/unmaping the destination mem if 
+        * required (or not if DMA) 
+        */
+
+       buffer = map_domain_mem(virt_to_phys(vbuffer));
+
        io_32bit = drive->io_32bit;
 
        if (io_32bit) {
@@ -453,21 +462,26 @@ void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 #endif /* SUPPORT_SLOW_DATA_PORTS */
                        insw(IDE_DATA_REG, buffer, wcount<<1);
        }
+
+        unmap_domain_mem(buffer);
 }
 
 /*
  * This is used for most PIO data transfers *to* the IDE interface
  */
-void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+void ide_output_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
 {
+        void *buffer;
        byte io_32bit;
 
        if(HWIF(drive)->ideproc) {
                HWIF(drive)->ideproc(ideproc_ide_output_data,
-                                    drive, buffer, wcount);
+                                    drive, vbuffer, wcount);
                return;
        }
 
+       buffer = map_domain_mem(virt_to_phys(vbuffer));
+
        io_32bit = drive->io_32bit;
 
        if (io_32bit) {
@@ -494,6 +508,8 @@ void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 #endif /* SUPPORT_SLOW_DATA_PORTS */
                        outsw(IDE_DATA_REG, buffer, wcount<<1);
        }
+
+       unmap_domain_mem(buffer);
 }
 
 /*
@@ -510,7 +526,7 @@ void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount
                                     drive, buffer, bytecount);
                return;
        }
-
+printk("XXXXX atapi_input_bytes called -- mapping is likely broken\n");
        ++bytecount;
 #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
        if (MACH_IS_ATARI || MACH_IS_Q40) {
@@ -532,6 +548,8 @@ void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecoun
                return;
        }
 
+printk("XXXXX atapi_output_bytes called -- mapping is likely broken\n");
+
        ++bytecount;
 #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
        if (MACH_IS_ATARI || MACH_IS_Q40) {